package com.doit.hbase.client;

import com.doit.hbase.utils.HbaseUtils;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;

/**
 * @DATE 2021/12/13/15:41
 * @Author MDK
 * @Version 2021.2.2
 *
 * 添加多个列族tb_order2,  增加参数的设置tb_order3
 **/
public class C06_CreateTable02 {
    public static void main(String[] args) throws Exception {
        Connection conn = HbaseUtils.getConnection();
        Admin admin = HbaseUtils.getAdmin(conn);

        //表构造器
        TableDescriptorBuilder tblb = TableDescriptorBuilder.newBuilder(TableName.valueOf("tb_city2"));
        //列族一
        ColumnFamilyDescriptorBuilder cf1b = ColumnFamilyDescriptorBuilder.newBuilder("cf1".getBytes());
        ColumnFamilyDescriptor cf1 = cf1b.build();
        tblb.setColumnFamily(cf1);

        //建表
        TableDescriptor tb1 = tblb.build();
        //指定切割点
        byte[][] keys = {"h".getBytes(), "s".getBytes()};
        //创建预分region表
        admin.createTable(tb1,keys);
        admin.close();
        conn.close();
    }
}
